/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Taikhoan;

import java.util.ArrayList;

/**
 *
 * @author Sinz
 */
public class AccountsList {

    private ArrayList<Account> accList;

    public AccountsList() {
        this.accList = new ArrayList<Account>();
        this.accList.add(new Account("admin", "admin", 1));
        this.accList.add(new Account("manager", "manager", 2));
        this.accList.add(new Account("seller", "seller", 3));
    }

    public ArrayList<Account> getAccList() {
        return accList;
    }

    public void setAccList(ArrayList<Account> accList) {
        this.accList = accList;
    }

    //
    public int getCount() {
        return this.accList.size();
    }

    //

    public void addAcc(Account acc) {
        this.accList.add(acc);
    }

    //

    public boolean removeAcc(String accName) {
        for (Account acc : this.accList) {
            if (acc.getName().equals(accName)) {
                this.accList.remove(acc);
            }
            return true;
        }
        return false;
    }

    //

    public Account isExist(String user, char[] pass) {
        for (Account acc : this.accList) {
            if (acc.autAccount(user, pass)) {
                return acc;
            }
        }
        return null;
    }
}
